import request from '@/utils/request'
import dao from '@/utils/daoji';
import java from '@/utils/zhou';
import https from '@/utils/http';
import store from '@/store'

export const index = data => {
  return request({
    method: 'POST',
    url: '/activity/list',
    data
  })
}

// 是否完成浏览任务状态
export function canBrowse (data) {
  return dao({
    url: `/api/v3/prize/finish/status`,
    method: 'post',
    data,
    hideLoading: 1
  })
}
// 完成任务
export function finishQuest (data) {
  return dao({
    url: `/api/v3/prize/finish/view`,
    method: 'post',
    data,
    hideLoading: 1
  })
}
// 领取优惠卷
export function Coupon (data) {
  return dao({
    url: `/api/v1/getcoupon`,
    method: 'post',
    data,
    hideLoading: 1
  })
}
// 获取中奖信息
export const Winning = data => {
  return request({
    method: 'POST',
    url: 'winner/list',
    data
  })
}
// 获取20  100优惠卷
export function Coupons (data) {
  return dao({
    url: `/api/v5/get/mayday/coupon`,
    method: 'post',
    data,
  })
}
// 领取20  100优惠卷
export function Coupondev (data) {
  return dao({
    url: `/api/v1/getcoupon`,
    method: 'post',
    data,
  })
}
// 新人频道
export function getNewData (data) {
  return dao({
    url: `/api/v3/new/user/activity`,
    method: 'post',
    data,
  })
}
// 判断用户是否新用户
export function NewPeople (data) {
  return dao({
    url: `/api/v3/user/is/new`,
    method: 'post',
    data,
  })
}
// 领取新人频道多张优惠卷
export function NewHot (data) {
  return dao({
    url: `/api/v1/getmulticoupon`,
    method: 'post',
    data,
  })
}
// 超值预约
// 获取今日预约的活动
export function GetDay (params) {
  return java({
    url: `/app/presaleActivity/getTodayActivityList`,
    method: 'get',
    params
  })
}
// 获取今日预约的活动商品
export function GetDayList (params) {
  return java({
    url: `/app/presaleActivity/getTodayGoodsList`,
    method: 'get',
    params
  })
}
// 获取明日预告活动
export function GetMin (params) {
  return java({
    url: `/app/presaleActivity/getTomorrowActivityList`,
    method: 'get',
    params
  })
}
// 获取指定活动指定商品的预约信息列表
export function Getlist (params) {
  return java({
    url: `/app/presaleActivity/getWinnerList`,
    method: 'get',
    params
  })
}
// 618
// 检测是否可以参与
export function testing (data) {
  return dao({
    url: `/api/v6/red/check`,
    method: 'post',
    data,
  })
}
// 领取红包
export function receive (data) {
  return dao({
    url: `/api/v6/red/ling`,
    method: 'post',
    data,
  })
}
// java
//
// 获取登录用户拉新数量
export function Getall () {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/pullNewActivity/countMyPullPeople`,
    method: 'get',
  })
}
// 获取我的信息和本次活动排行信息(app进度条页面, 可区分是否参与活动)
export function GetNewall () {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/pullNewActivity/findMyActivityProcessBar`,
    method: 'get',
  })
}
// 获取本期排行和上期排行信息
export function Updown (params) {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/pullNewActivity/findMyActivityRewardInfo`,
    method: 'get',
    params
  })
}
//获取我的信息和本次活动排行信息
export function Getmi () {
  return java({
    // headers: {
    //   'Content-Type': 'application/json'
    // },
    url: `/app/pullNewActivity/findMyActivityMessage`,
    method: 'get',
  })
}
// 根据手机号获取验证码
export function Yan (params) {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/mas/getPhoneVerifyCode`,
    method: 'get',
    params,
  })
}
// 验证手机验证码
export function Mobile (data) {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/pullNewActivity/verifyIfNewUser`,
    method: 'post',
    data,
  })
}
// 判断是否店主
export function judge () {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/pullNewActivity/ifStationHolder`,
    method: 'get',
  })
}
// 周年礼遇
// 获取当前可领取优惠卷id
export function Recharge () {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/tempUserLables/getCouponInfo`,
    method: 'get',
  })
}
//领取优惠卷
export function receivetwo (data) {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/tempUserLables/addMyCouponBag`,
    method: 'post',
    data
  })
}
// 转盘抽奖
export function Frequency () {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/drowPrize/getChanceCountOfUser`,
    method: 'get',
  })
}
// 获取抽奖信息
export function doDraw (data) {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/drowPrize/doDraw`,
    method: 'post',
    data
  })
}
// 查询中奖记录
export function Win () {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/drowPrize/getPrizeRecordList`,
    method: 'get',
  })
}
// 查询抽奖记录
export function Luckdraw () {
  return java({
    // headers: {
    //   'Content-Type': 'application/x-www-form-urlencoded'
    // },
    url: `/app/drowPrize/getDrawRecordList`,
    method: 'get',
  })
}

const { gettoken } = store.state;
let Base64 = require('js-base64').Base64

//转盘第二期
// 获取抽奖次数
export function numberDraws (version, token, did, typePed, sign, time, model) {
  let vers = 'version=' + version + '&token=' + token + '&did=' + did + '&type=' + typePed + '&sign=' + sign + '&time=' + time + '&model=' + model;
  return https({
    url: "/app/yfdOemActivity/getLotteryCounts" + '?headerParam=' + Base64.encode(vers),
    method: "get",
  })
}
// 查询中奖记录
export function winDeras (type, version, token, did, typePed, sign, time, model) {
  let vers = 'version=' + version + '&token=' + token + '&did=' + did + '&type=' + typePed + '&sign=' + sign + '&time=' + time + '&model=' + model;
  return https({
    url: `/app/yfdOemActivity/getRecordlist/` + `${type}` + "?id=63" + '&headerParam=' + Base64.encode(vers),
    method: "get",
  })
}
//.replace(/\+/g, "%2B")
//抽奖
export function lottery (id, version, token, did, typePed, sign, time, model) {
  let vers = 'version=' + version + '&token=' + token + '&did=' + did + '&type=' + typePed + '&sign=' + sign + '&time=' + time + '&model=' + model;
  return https({
    url: "/app/yfdOemActivity/lottery?id=" + `${id}` + '&headerParam=' + Base64.encode(vers),
    method: "post",
  })
}